package day2.cases.traittest

/**
  * Created by Administrator on 2017/6/8.
  */
trait sayHello {
  //抽象字段
  val msg:String
  def sayHello(name:String)=println(msg +" , "+name)
}
class Person2(val name:String) extends sayHello{
  val msg:String = "hello"
  def makeFriends(p:Person2): Unit ={
    sayHello(p.name)
    println("I'm"+name +" I want to make frieds with you")
  }
}
object testperson2{
  def main(args: Array[String]): Unit = {
    val p1=new Person2("zhangwuji")
    val p2=new Person2("zhangsanfeng")
    p1.makeFriends(p2)
  }
}
